//#include "stdafx.h"
#include "QueryOptimizer.h"
#include <vector>
#include <list>
#include <string>
#include <iostream>
using std::vector;
using namespace std;
class QueryEvaluator
{
	
private:
	Query_Preprocessor queryPreprocessor;
	vector<suchThatClause> suchThat;
	struct Result result;
	vector<patternClause> pattern;
	vector<withClause> with;
	vector<vector<int>> withMapping;
	struct Result independentResult;
	QueryProcessor query;

public:
	QueryEvaluator();
	int clearWithMapping();
	int executeQuery(list<string>& resultVector);
	int validateQuery(string Query,list<string> &resultVector);
	void generateMapping(int,vector<string>& variables);
	void getEntityMapping(struct Result &result,list<string>& resultVector);
	int getWithMapping(int&,int,int);
	int intersectResult(struct Result& resultTemp,vector<int>& result1, vector<int>& result2,struct Argument& argument1, struct Argument& argument2,int both);
	int deleteRow(struct Result& resultTemp, int rowIndex); 	
	int checkIndependence(struct Result& tempResult,struct Argument& argument1, struct Argument& argument2,int both);
	int checkEmpty(struct Result& tempResult);
	int deleteAllRows(struct Result& tempResult);
	int clearResult(struct Result& tempResult);
	int checkWithMapping(int argument,int argumentInd, int argumentResult);
	int checkArgumentNecessity(struct Result& tempResult, Argument argTemp, vector<suchThatClause>& tempSuchThat);

};